/* ====================================================================
 * (#)Header: PropertyIndicator.java
 * (#)Revision: 
 * (#)Date Created: Jun 8, 2013
 * (#)Created By: Karol Wozniak
 * ====================================================================
 *
 * Copyright (c) 2013 karolak .  All rights reserved.
 *
 * ====================================================================
 * 
 * The software application represented here is the sole property of 
 * karolak. Its unauthorized utilization is expressly prohibited.
 * 
 * ====================================================================
 */

package com.karolak.stock.indicator;

import com.karolak.bean.BeanUtils;
import com.karolak.stock.data.DataManager;

public class PropertyInd extends Indicator {

	private String propertyName;
	private Object[] params;

	public PropertyInd(DataManager dataManager, Indicator input, String propertyName) {
		super(dataManager, 0, input);
		this.propertyName = propertyName;
	}
	
	public PropertyInd(String name, DataManager dataManager, Indicator input, String propertyName, Object... params) {
		super(name, dataManager, 0, input);
		this.propertyName = propertyName;
		this.params = params;
	}	

	@Override
	public double execute(double x) {
		return BeanUtils.getPropertyValue(getInput(), getPropertyName(), getParams());
	}

	protected String getPropertyName() {
		return propertyName;
	}

	protected Object[] getParams() {
		return params;
	}

	protected void setParams(Object[] params) {
		this.params = params;
	}
}
